{include file="public/header" /}
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>{$Think.lang.fuwu_personal}</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>
        <form id="form" method="post" name="form1">
            <input type="hidden" name="id" value="{$data.id}" id="id"/>
            <table class="ds-default-table">
                <tbody>
                <tr class="noborder">
                    <td class="required w120">省份:</td>
                    <td class="vatop rowform">
                        <select name="provice">
                            <!--<option value="">&#45;&#45;请选择</option>-->
                            {foreach name="topArr" item='v'}
                                    <option value="{$v.area_id}" {if $data.provice==$v.area_id} selected{/if}>{$v.area_name}</option>
                            {/foreach}
                        </select>
                    </td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="required w120">城市:</td>
                    <td class="vatop rowform">
                        <select name="city" readonly="readonly">
                            <!--<option value="">&#45;&#45;请选择</option>-->
                            {foreach name="twoArr" item='v'}
                            <option value="{$v.area_id}" {if $data.city==$v.area_id} selected{/if}>{$v.area_name}</option>
                            {/foreach}
                        </select>
                    </td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="required w120"><label>{$Think.lang.fuwu_personal_status}: </label></td>
                    <td class="vatop rowform onoff">
                        <label for="status1" class="cb-enable {if $data.status == '1'}selected{/if}" title="{$Think.lang.fuwu_personal_status1}"><span>{$Think.lang.fuwu_personal_status1}</span></label>
                        <label for="status0" class="cb-disable {if $data.status == '0'}selected{/if}" title="{$Think.lang.fuwu_personal_status0}"><span>{$Think.lang.fuwu_personal_status0}</span></label>
                        <input id="status1" name="status" {if $data.status == '1'}checked="checked"{/if} value="1" type="radio">
                        <input id="status0" name="status" {if $data.status == '0'}checked="checked"{/if} value="0" type="radio">
                    </td>
                    <td class="vatop tips"></td>
                </tr>     <tr class="noborder">
                    <td class="required w120">区域:</td>
                    <td class="vatop rowform" colspan="2">
                        <div class="last2" style=" margin:10px;">
                            {foreach name="threeArr" item='v'}
                            <i class="dtree-icon-shuye1 dtreefont-special dtree-theme-dtreefont dtree-theme-icon"></i>
                            <input type="checkbox" value="{$v.area_id}" class="aaa" name="areaid[]"
                                   {if strpos($data.areaid,(string)$v.area_id) !== false} checked {/if}>{$v.area_name}
                            {/foreach}
                        </div>
                    </td>
                    <!--<td class="vatop tips"></td>-->
                </tr>

                </tbody>
                <tfoot>
                <tr class="tfoot">
                    <td colspan="15" ><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
                </tr>
                </tfoot>
            </table>
        </form>
    </div>
<script src="{$Think.PLUGINS_SITE_ROOT}/mlselection.js"></script>
<link rel="stylesheet" href="{$Think.CHAT_SITE_URL}/css/chat.css">
<script>
//按钮先执行验证再提交表
    $(document).ready(function () {
        $("#form").validate({
        errorPlacement: function (error,element) {
                error.appendTo(element.parent().parent().find('td:last'));
            },
            rules:{
                skillid:{
                  required:true
                },
                phone:{
                    required:true,
                    checkphone:true,
                    remote:{
                        url: ADMINSITEURL+'/Fupersonal/ajax.html?branch=check_phone',
                        type:'get',
                        data:{
                            phone:function () {
                                return $('#phone').val();
                            },
                            id:function () {
                                return $('#id').val();
                            }
                        }
                    }
                },
                password:{
                    required:true,
                    minlength:6
                },
                quren_password:{
                    required:true,
                    equalTo:"#password"
                },
            },
            messages:{
                skillid:{
                    required:'{$Think.lang.fuwu_personal_skillid_bi}',
                },
                phone:{
                    required:'{$Think.lang.fuwu_personal_phone_bi}',
                    remote:'{$Think.lang.fuwu_personal_phone_unique}',

                },
                password:{
                    required:'{$Think.lang.fuwu_personal_password_bi}',
                    minlength:'{$Think.lang.fuwu_personal_password_min}',
                },
                quren_password:{
                    required:'{$Think.lang.fuwu_personal_quren_password_bi}',
                    equalTo:'{$Think.lang.fuwu_personal_quren_password_tong}',
                },
            }
        });
        //自定义正则表达示验证方法
        $.validator.addMethod("checkphone",function(value,element,params){
            var checkQQ = /^[1][3,4,5,7,8,9][0-9]{9}$/;
            return this.optional(element)||(checkQQ.test(value));
        },"{$Think.lang.fuwu_personal_phone_geshi}");
    });
$(document).on('change','#upload_img',function() {
    var files = document.getElementById('upload_img').files[0];
    var formData = new FormData();
    formData.append('file',files);
    layer.msg('正在上传，请稍后');
    $.ajax({
        //请求方式
        type : "POST",
        //请求地址
        url : "ajax_upload",
        data : formData,
        cache:false,  //默认是true，但是一般不做缓存
        processData:false, //用于对data参数进行序列化处理，这里必须false；如果是true，就会将FormData转换为String类型
        contentType:false,  //一些文件上传http协议的关系，自行百度，如果上传的有文件，那么只能设置为false
        //请求成功
        success : function(result) {
            if(result.err==0){
                layer.msg(result.msg);
                $('#avtar').val(result.data);
            }else{
                $('#avtar').val('');
                alert('文件信息错误,请重新上传');return false;
            }



        },
        //请求失败，包含具体的错误信息
        error : function(e){
            console.log(e.status);
            console.log(e.responseText);
        }
    });

});
</script>